#ifndef SOCKETMANAGER_H
#define SOCKETMANAGER_H

#include <QObject>
#include <QSslSocket>

class SocketManager : public QObject
{
    Q_OBJECT
public:
    explicit SocketManager(QObject *parent = nullptr);
    void connectToServer(const QString &host, quint16 port);
    void sendData(const QByteArray &data);
    void loadCaCertificate(const QString &certFilePath);

signals:
    void connectionFailed(const QString &errorMessage);
    void dataReceived(const QByteArray &data);

private slots:
    void onSslErrors(const QList<QSslError> &errors);
    void onReadyRead();
    void onStateChanged(QAbstractSocket::SocketState state);

private:
    QSslSocket *sslSocket;
};

#endif // SOCKETMANAGER_H
